function getCookie(name) {
    var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
    return r ? r[1] : undefined;
}


$(function () {

    $(".focused").click(function () {
        // 1、获取需要取消的关注的用户id
        var new_id = $(this).attr("new_id")
        console.log(new_id)
        // 需要上传的是数据
        var send_data = {
            user_id: new_id,
            action: "unfollow",
        }

        $.ajax({
            url: "/news/followed_user",
            type: "post",
            contentType: "application/json",
            headers: {
                "X-CSRFToken": getCookie('csrf_token')
            },
            data: JSON.stringify(send_data),
            success: function (data) {
                if (data.errno == "0") {
                    alert(data.errmsg)
                    window.location.reload()
                } else {
                    alert(data.errmsg)
                }
            }
        })

    })
})